package com.guoxin.designpattern.chapter6;

/**
 * @author guoxin
 * @date 2019/9/4
 */
public class ReaderWorker extends Thread {
    private final ShareData shareData;

    public ReaderWorker(ShareData shareData) {
        this.shareData = shareData;
    }

    @Override
    public void run() {
        try {
            for (; ; ) {
                char[] c = shareData.read();
                System.out.println(Thread.currentThread().getName() + " reads " + String.valueOf(c));
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
